{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "9c085e9d",
   "metadata": {},
   "source": [
    "# Test a ready kernel"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "93cdc330-9553-4750-9f9b-ced2c9da81e2",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Instr =  0 ( 0 )\n",
      "[   1,    1,    1,    9]    [LWD , LWD , LWD , LWD ]    [2.96e-05, 2.96e-05, 2.96e-05, 2.96e-05]    [3.26e-12, 3.26e-12, 3.26e-12, 3.26e-12]    \n",
      "[   2,    2,    2,    0]    [LWD , LWD , LWD , NOP ]    [2.96e-05, 2.96e-05, 2.96e-05, 2.80e-05]    [3.26e-12, 3.26e-12, 3.26e-12, 3.08e-12]    \n",
      "[   3,    3,    3,    0]    [LWD , LWD , LWD , NOP ]    [2.96e-05, 2.96e-05, 2.96e-05, 2.80e-05]    [3.26e-12, 3.26e-12, 3.26e-12, 3.08e-12]    \n",
      "[   0,    0,    0,    0]    [NOP , NOP , NOP , NOP ]    [2.80e-05, 2.80e-05, 2.80e-05, 2.80e-05]    [3.08e-12, 3.08e-12, 3.08e-12, 3.08e-12]    \n",
      "Power: 4.64e-04 W, Energy: 5.10e-11 J\n",
      "Latency: 11 cc\n",
      "-------\n",
      "Instr =  1 ( 1 )\n",
      "[   2,    2,    2,    6]    [SMUL, SMUL, SMUL, SSUB]    [1.85e-04, 1.85e-04, 1.85e-04, 1.00e-04]    [5.56e-12, 5.56e-12, 5.56e-12, 3.01e-12]    \n",
      "[   4,    4,    4,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.85e-04, 1.85e-04, 1.85e-04, 3.54e-05]    [5.56e-12, 5.56e-12, 5.56e-12, 1.06e-12]    \n",
      "[   6,    6,    6,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.85e-04, 1.85e-04, 1.85e-04, 3.54e-05]    [5.56e-12, 5.56e-12, 5.56e-12, 1.06e-12]    \n",
      "[   0,    0,    0,    0]    [NOP , NOP , NOP , NOP ]    [3.54e-05, 3.54e-05, 3.54e-05, 3.54e-05]    [1.06e-12, 1.06e-12, 1.06e-12, 1.06e-12]    \n",
      "Power: 1.98e-03 W, Energy: 5.94e-11 J\n",
      "Latency: 3 cc\n",
      "-------\n",
      "Instr =  2 ( 2 )\n",
      "[   1,    1,    1,    9]    [SADD, SADD, SADD, BEQ ]    [9.45e-05, 9.45e-05, 9.45e-05, 4.96e-05]    [9.45e-13, 9.45e-13, 9.45e-13, 4.96e-13]    \n",
      "[   2,    2,    2,    0]    [SADD, SADD, SADD, NOP ]    [9.45e-05, 9.45e-05, 9.45e-05, 4.86e-05]    [9.45e-13, 9.45e-13, 9.45e-13, 4.86e-13]    \n",
      "[  10,   10,   10,    0]    [SADD, SADD, SADD, NOP ]    [9.79e-05, 9.79e-05, 9.79e-05, 4.86e-05]    [9.79e-13, 9.79e-13, 9.79e-13, 4.86e-13]    \n",
      "[   2,    2,    2,    0]    [SADD, SADD, SADD, NOP ]    [9.79e-05, 9.79e-05, 9.79e-05, 4.86e-05]    [9.79e-13, 9.79e-13, 9.79e-13, 4.86e-13]    \n",
      "Power: 1.35e-03 W, Energy: 1.35e-11 J\n",
      "Latency: 1 cc\n",
      "-------\n",
      "Instr =  3 ( 3 )\n",
      "[   4,    4,    4,    9]    [LWD , LWD , LWD , NOP ]    [5.50e-05, 5.50e-05, 5.50e-05, 3.44e-05]    [2.20e-12, 2.20e-12, 2.20e-12, 1.38e-12]    \n",
      "[   1,    1,    1,    0]    [SADD, SADD, SADD, NOP ]    [9.26e-05, 9.26e-05, 9.26e-05, 3.44e-05]    [3.70e-12, 3.70e-12, 3.70e-12, 1.38e-12]    \n",
      "[   2,    2,    2,    0]    [SADD, SADD, SADD, NOP ]    [9.26e-05, 9.26e-05, 9.26e-05, 3.44e-05]    [3.70e-12, 3.70e-12, 3.70e-12, 1.38e-12]    \n",
      "[  12,   12,   12,    0]    [SADD, SADD, SADD, NOP ]    [9.26e-05, 9.26e-05, 9.26e-05, 3.44e-05]    [3.70e-12, 3.70e-12, 3.70e-12, 1.38e-12]    \n",
      "Power: 1.14e-03 W, Energy: 4.54e-11 J\n",
      "Latency: 4 cc\n",
      "-------\n",
      "Instr =  4 ( 4 )\n",
      "[   8,    8,    8,    5]    [SMUL, SMUL, SMUL, SSUB]    [1.85e-04, 1.85e-04, 1.85e-04, 1.00e-04]    [5.56e-12, 5.56e-12, 5.56e-12, 3.01e-12]    \n",
      "[   2,    2,    2,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.85e-04, 1.85e-04, 1.85e-04, 3.54e-05]    [5.56e-12, 5.56e-12, 5.56e-12, 1.06e-12]    \n",
      "[   4,    4,    4,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.85e-04, 1.85e-04, 1.85e-04, 3.54e-05]    [5.56e-12, 5.56e-12, 5.56e-12, 1.06e-12]    \n",
      "[  24,   12,   12,   12]    [SADD, NOP , NOP , SADD]    [9.70e-05, 3.54e-05, 3.54e-05, 9.70e-05]    [2.91e-12, 1.06e-12, 1.06e-12, 2.91e-12]    \n",
      "Power: 2.11e-03 W, Energy: 6.32e-11 J\n",
      "Latency: 3 cc\n",
      "-------\n",
      "Instr =  5 ( 5 )\n",
      "[   4,    4,    4,    9]    [SADD, SADD, SADD, BEQ ]    [9.46e-05, 9.46e-05, 9.46e-05, 4.97e-05]    [9.46e-13, 9.46e-13, 9.46e-13, 4.97e-13]    \n",
      "[   1,    1,    1,    0]    [SADD, SADD, SADD, NOP ]    [9.46e-05, 9.46e-05, 9.46e-05, 4.86e-05]    [9.46e-13, 9.46e-13, 9.46e-13, 4.86e-13]    \n",
      "[   6,    6,    6,    0]    [SADD, SADD, SADD, NOP ]    [9.80e-05, 9.80e-05, 9.80e-05, 4.86e-05]    [9.80e-13, 9.80e-13, 9.80e-13, 4.86e-13]    \n",
      "[   8,    8,    8,   36]    [SADD, SADD, SADD, SADD]    [9.79e-05, 9.80e-05, 9.80e-05, 9.79e-05]    [9.79e-13, 9.80e-13, 9.80e-13, 9.79e-13]    \n",
      "Power: 1.40e-03 W, Energy: 1.40e-11 J\n",
      "Latency: 1 cc\n",
      "-------\n",
      "Instr =  6 ( 6 )\n",
      "[   5,    5,    5,    9]    [LWD , LWD , LWD , NOP ]    [4.96e-05, 4.96e-05, 4.96e-05, 3.44e-05]    [2.48e-12, 2.48e-12, 2.48e-12, 1.72e-12]    \n",
      "[   4,    4,    4,    0]    [SADD, SADD, SADD, NOP ]    [9.26e-05, 9.26e-05, 9.26e-05, 3.44e-05]    [4.63e-12, 4.63e-12, 4.63e-12, 1.72e-12]    \n",
      "[   1,    1,    1,    0]    [SADD, SADD, SADD, NOP ]    [9.26e-05, 9.26e-05, 9.26e-05, 3.44e-05]    [4.63e-12, 4.63e-12, 4.63e-12, 1.72e-12]    \n",
      "[  14,   14,   14,   36]    [SADD, SADD, SADD, SWD ]    [9.26e-05, 9.26e-05, 9.26e-05, 3.06e-05]    [4.63e-12, 4.63e-12, 4.63e-12, 1.53e-12]    \n",
      "Power: 1.12e-03 W, Energy: 5.58e-11 J\n",
      "Latency: 5 cc\n",
      "-------\n",
      "Instr =  7 ( 7 )\n",
      "[  10,   10,   10,    4]    [SMUL, SMUL, SMUL, SSUB]    [1.86e-04, 1.86e-04, 1.86e-04, 1.00e-04]    [5.57e-12, 5.57e-12, 5.57e-12, 3.01e-12]    \n",
      "[   8,    8,    8,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.86e-04, 1.86e-04, 1.86e-04, 3.54e-05]    [5.57e-12, 5.57e-12, 5.57e-12, 1.06e-12]    \n",
      "[   2,    2,    2,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.86e-04, 1.86e-04, 1.86e-04, 3.54e-05]    [5.57e-12, 5.57e-12, 5.57e-12, 1.06e-12]    \n",
      "[  28,   14,   14,   14]    [SADD, NOP , NOP , SADD]    [9.70e-05, 3.55e-05, 3.55e-05, 9.70e-05]    [2.91e-12, 1.06e-12, 1.06e-12, 2.91e-12]    \n",
      "Power: 2.11e-03 W, Energy: 6.32e-11 J\n",
      "Latency: 3 cc\n",
      "-------\n",
      "Instr =  8 ( 8 )\n",
      "[   5,    5,    5,    6]    [SADD, SADD, SADD, BNE ]    [9.47e-05, 9.47e-05, 9.47e-05, 4.98e-05]    [9.47e-13, 9.47e-13, 9.47e-13, 4.98e-13]    \n",
      "[   4,    4,    4,    0]    [SADD, SADD, SADD, NOP ]    [9.47e-05, 9.47e-05, 9.47e-05, 4.86e-05]    [9.47e-13, 9.47e-13, 9.47e-13, 4.86e-13]    \n",
      "[  10,   10,   10,    0]    [SADD, SADD, SADD, NOP ]    [9.81e-05, 9.81e-05, 9.81e-05, 4.86e-05]    [9.81e-13, 9.81e-13, 9.81e-13, 4.86e-13]    \n",
      "[  10,   10,   10,   42]    [SADD, SADD, SADD, SADD]    [9.79e-05, 9.81e-05, 9.81e-05, 9.79e-05]    [9.79e-13, 9.81e-13, 9.81e-13, 9.79e-13]    \n",
      "Power: 1.40e-03 W, Energy: 1.40e-11 J\n",
      "Latency: 1 cc\n",
      "-------\n",
      "Instr =  9 ( 6 )\n",
      "[   6,    6,    6,    6]    [LWD , LWD , LWD , NOP ]    [4.97e-05, 4.97e-05, 4.97e-05, 3.44e-05]    [2.48e-12, 2.48e-12, 2.48e-12, 1.72e-12]    \n",
      "[   5,    5,    5,    0]    [SADD, SADD, SADD, NOP ]    [9.27e-05, 9.27e-05, 9.27e-05, 3.44e-05]    [4.63e-12, 4.63e-12, 4.63e-12, 1.72e-12]    \n",
      "[   4,    4,    4,    0]    [SADD, SADD, SADD, NOP ]    [9.27e-05, 9.27e-05, 9.27e-05, 3.44e-05]    [4.63e-12, 4.63e-12, 4.63e-12, 1.72e-12]    \n",
      "[  20,   20,   20,   42]    [SADD, SADD, SADD, SWD ]    [9.26e-05, 9.27e-05, 9.27e-05, 3.06e-05]    [4.63e-12, 4.63e-12, 4.63e-12, 1.53e-12]    \n",
      "Power: 1.12e-03 W, Energy: 5.58e-11 J\n",
      "Latency: 5 cc\n",
      "-------\n",
      "Instr =  10 ( 7 )\n",
      "[  12,   12,   12,    3]    [SMUL, SMUL, SMUL, SSUB]    [1.86e-04, 1.86e-04, 1.86e-04, 1.01e-04]    [5.57e-12, 5.57e-12, 5.57e-12, 3.02e-12]    \n",
      "[  10,   10,   10,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.86e-04, 1.86e-04, 1.86e-04, 3.54e-05]    [5.57e-12, 5.57e-12, 5.57e-12, 1.06e-12]    \n",
      "[   8,    8,    8,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.86e-04, 1.86e-04, 1.86e-04, 3.54e-05]    [5.57e-12, 5.57e-12, 5.57e-12, 1.06e-12]    \n",
      "[  40,   20,   20,   20]    [SADD, NOP , NOP , SADD]    [9.70e-05, 3.55e-05, 3.55e-05, 9.70e-05]    [2.91e-12, 1.07e-12, 1.07e-12, 2.91e-12]    \n",
      "Power: 2.11e-03 W, Energy: 6.32e-11 J\n",
      "Latency: 3 cc\n",
      "-------\n",
      "Instr =  11 ( 8 )\n",
      "[   6,    6,    6,    6]    [SADD, SADD, SADD, BNE ]    [9.48e-05, 9.48e-05, 9.48e-05, 5.00e-05]    [9.48e-13, 9.48e-13, 9.48e-13, 5.00e-13]    \n",
      "[   5,    5,    5,    0]    [SADD, SADD, SADD, NOP ]    [9.48e-05, 9.48e-05, 9.48e-05, 4.86e-05]    [9.48e-13, 9.48e-13, 9.48e-13, 4.86e-13]    \n",
      "[  18,   18,   18,    0]    [SADD, SADD, SADD, NOP ]    [9.82e-05, 9.82e-05, 9.82e-05, 4.86e-05]    [9.82e-13, 9.82e-13, 9.82e-13, 4.86e-13]    \n",
      "[  12,   12,   12,   60]    [SADD, SADD, SADD, SADD]    [9.79e-05, 9.82e-05, 9.82e-05, 9.79e-05]    [9.79e-13, 9.82e-13, 9.82e-13, 9.79e-13]    \n",
      "Power: 1.40e-03 W, Energy: 1.40e-11 J\n",
      "Latency: 1 cc\n",
      "-------\n",
      "Instr =  12 ( 6 )\n",
      "[   7,    7,    7,    6]    [LWD , LWD , LWD , NOP ]    [4.97e-05, 4.97e-05, 4.97e-05, 3.45e-05]    [2.48e-12, 2.48e-12, 2.48e-12, 1.72e-12]    \n",
      "[   6,    6,    6,    0]    [SADD, SADD, SADD, NOP ]    [9.27e-05, 9.27e-05, 9.27e-05, 3.44e-05]    [4.63e-12, 4.63e-12, 4.63e-12, 1.72e-12]    \n",
      "[   5,    5,    5,    0]    [SADD, SADD, SADD, NOP ]    [9.27e-05, 9.27e-05, 9.27e-05, 3.44e-05]    [4.63e-12, 4.63e-12, 4.63e-12, 1.72e-12]    \n",
      "[  30,   30,   30,   60]    [SADD, SADD, SADD, SWD ]    [9.26e-05, 9.27e-05, 9.27e-05, 3.06e-05]    [4.63e-12, 4.63e-12, 4.63e-12, 1.53e-12]    \n",
      "Power: 1.12e-03 W, Energy: 5.59e-11 J\n",
      "Latency: 5 cc\n",
      "-------\n",
      "Instr =  13 ( 7 )\n",
      "[  14,   14,   14,    2]    [SMUL, SMUL, SMUL, SSUB]    [1.86e-04, 1.86e-04, 1.86e-04, 1.01e-04]    [5.57e-12, 5.57e-12, 5.57e-12, 3.02e-12]    \n",
      "[  12,   12,   12,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.86e-04, 1.86e-04, 1.86e-04, 3.54e-05]    [5.57e-12, 5.57e-12, 5.57e-12, 1.06e-12]    \n",
      "[  10,   10,   10,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.86e-04, 1.86e-04, 1.86e-04, 3.54e-05]    [5.57e-12, 5.57e-12, 5.57e-12, 1.06e-12]    \n",
      "[  60,   30,   30,   30]    [SADD, NOP , NOP , SADD]    [9.70e-05, 3.56e-05, 3.56e-05, 9.70e-05]    [2.91e-12, 1.07e-12, 1.07e-12, 2.91e-12]    \n",
      "Power: 2.11e-03 W, Energy: 6.32e-11 J\n",
      "Latency: 3 cc\n",
      "-------\n",
      "Instr =  14 ( 8 )\n",
      "[   7,    7,    7,    6]    [SADD, SADD, SADD, BNE ]    [9.50e-05, 9.50e-05, 9.50e-05, 5.02e-05]    [9.50e-13, 9.50e-13, 9.50e-13, 5.02e-13]    \n",
      "[   6,    6,    6,    0]    [SADD, SADD, SADD, NOP ]    [9.50e-05, 9.50e-05, 9.50e-05, 4.86e-05]    [9.50e-13, 9.50e-13, 9.50e-13, 4.86e-13]    \n",
      "[  22,   22,   22,    0]    [SADD, SADD, SADD, NOP ]    [9.84e-05, 9.84e-05, 9.84e-05, 4.86e-05]    [9.84e-13, 9.84e-13, 9.84e-13, 4.86e-13]    \n",
      "[  14,   14,   14,   90]    [SADD, SADD, SADD, SADD]    [9.79e-05, 9.84e-05, 9.84e-05, 9.79e-05]    [9.79e-13, 9.84e-13, 9.84e-13, 9.79e-13]    \n",
      "Power: 1.40e-03 W, Energy: 1.40e-11 J\n",
      "Latency: 1 cc\n",
      "-------\n",
      "Instr =  15 ( 6 )\n",
      "[   8,    8,    8,    6]    [LWD , LWD , LWD , NOP ]    [4.97e-05, 4.97e-05, 4.97e-05, 3.45e-05]    [2.49e-12, 2.49e-12, 2.49e-12, 1.73e-12]    \n",
      "[   7,    7,    7,    0]    [SADD, SADD, SADD, NOP ]    [9.27e-05, 9.27e-05, 9.27e-05, 3.44e-05]    [4.64e-12, 4.64e-12, 4.64e-12, 1.72e-12]    \n",
      "[   6,    6,    6,    0]    [SADD, SADD, SADD, NOP ]    [9.27e-05, 9.27e-05, 9.27e-05, 3.44e-05]    [4.64e-12, 4.64e-12, 4.64e-12, 1.72e-12]    \n",
      "[  36,   36,   36,   90]    [SADD, SADD, SADD, SWD ]    [9.26e-05, 9.27e-05, 9.27e-05, 3.06e-05]    [4.63e-12, 4.64e-12, 4.64e-12, 1.53e-12]    \n",
      "Power: 1.12e-03 W, Energy: 5.59e-11 J\n",
      "Latency: 5 cc\n",
      "-------\n",
      "Instr =  16 ( 7 )\n",
      "[  16,   16,   16,    1]    [SMUL, SMUL, SMUL, SSUB]    [1.86e-04, 1.86e-04, 1.86e-04, 1.01e-04]    [5.57e-12, 5.57e-12, 5.57e-12, 3.02e-12]    \n",
      "[  14,   14,   14,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.86e-04, 1.86e-04, 1.86e-04, 3.54e-05]    [5.57e-12, 5.57e-12, 5.57e-12, 1.06e-12]    \n",
      "[  12,   12,   12,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.86e-04, 1.86e-04, 1.86e-04, 3.54e-05]    [5.57e-12, 5.57e-12, 5.57e-12, 1.06e-12]    \n",
      "[  72,   36,   36,   36]    [SADD, NOP , NOP , SADD]    [9.70e-05, 3.56e-05, 3.56e-05, 9.70e-05]    [2.91e-12, 1.07e-12, 1.07e-12, 2.91e-12]    \n",
      "Power: 2.11e-03 W, Energy: 6.32e-11 J\n",
      "Latency: 3 cc\n",
      "-------\n",
      "Instr =  17 ( 8 )\n",
      "[   8,    8,    8,    6]    [SADD, SADD, SADD, BNE ]    [9.51e-05, 9.51e-05, 9.51e-05, 5.03e-05]    [9.51e-13, 9.51e-13, 9.51e-13, 5.03e-13]    \n",
      "[   7,    7,    7,    0]    [SADD, SADD, SADD, NOP ]    [9.51e-05, 9.51e-05, 9.51e-05, 4.86e-05]    [9.51e-13, 9.51e-13, 9.51e-13, 4.86e-13]    \n",
      "[  26,   26,   26,    0]    [SADD, SADD, SADD, NOP ]    [9.85e-05, 9.85e-05, 9.85e-05, 4.86e-05]    [9.85e-13, 9.85e-13, 9.85e-13, 4.86e-13]    \n",
      "[  16,   16,   16,  108]    [SADD, SADD, SADD, SADD]    [9.79e-05, 9.85e-05, 9.85e-05, 9.79e-05]    [9.79e-13, 9.85e-13, 9.85e-13, 9.79e-13]    \n",
      "Power: 1.41e-03 W, Energy: 1.41e-11 J\n",
      "Latency: 1 cc\n",
      "-------\n",
      "Instr =  18 ( 6 )\n",
      "[   9,    9,    9,    6]    [LWD , LWD , LWD , NOP ]    [4.97e-05, 4.97e-05, 4.97e-05, 3.46e-05]    [2.49e-12, 2.49e-12, 2.49e-12, 1.73e-12]    \n",
      "[   8,    8,    8,    0]    [SADD, SADD, SADD, NOP ]    [9.27e-05, 9.27e-05, 9.27e-05, 3.44e-05]    [4.64e-12, 4.64e-12, 4.64e-12, 1.72e-12]    \n",
      "[   7,    7,    7,    0]    [SADD, SADD, SADD, NOP ]    [9.27e-05, 9.27e-05, 9.27e-05, 3.44e-05]    [4.64e-12, 4.64e-12, 4.64e-12, 1.72e-12]    \n",
      "[  42,   42,   42,  108]    [SADD, SADD, SADD, SWD ]    [9.26e-05, 9.27e-05, 9.27e-05, 3.06e-05]    [4.63e-12, 4.64e-12, 4.64e-12, 1.53e-12]    \n",
      "Power: 1.12e-03 W, Energy: 5.59e-11 J\n",
      "Latency: 5 cc\n",
      "-------\n",
      "Instr =  19 ( 7 )\n",
      "[  18,   18,   18,    0]    [SMUL, SMUL, SMUL, SSUB]    [1.86e-04, 1.86e-04, 1.86e-04, 1.01e-04]    [5.57e-12, 5.57e-12, 5.57e-12, 3.02e-12]    \n",
      "[  16,   16,   16,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.86e-04, 1.86e-04, 1.86e-04, 3.54e-05]    [5.57e-12, 5.57e-12, 5.57e-12, 1.06e-12]    \n",
      "[  14,   14,   14,    0]    [SMUL, SMUL, SMUL, NOP ]    [1.86e-04, 1.86e-04, 1.86e-04, 3.54e-05]    [5.57e-12, 5.57e-12, 5.57e-12, 1.06e-12]    \n",
      "[  84,   42,   42,   42]    [SADD, NOP , NOP , SADD]    [9.70e-05, 3.56e-05, 3.56e-05, 9.70e-05]    [2.91e-12, 1.07e-12, 1.07e-12, 2.91e-12]    \n",
      "Power: 2.11e-03 W, Energy: 6.32e-11 J\n",
      "Latency: 3 cc\n",
      "-------\n",
      "Instr =  20 ( 8 )\n",
      "[   9,    9,    9,    6]    [SADD, SADD, SADD, BNE ]    [9.52e-05, 9.52e-05, 9.52e-05, 5.05e-05]    [9.52e-13, 9.52e-13, 9.52e-13, 5.05e-13]    \n",
      "[   8,    8,    8,    0]    [SADD, SADD, SADD, NOP ]    [9.52e-05, 9.52e-05, 9.52e-05, 4.86e-05]    [9.52e-13, 9.52e-13, 9.52e-13, 4.86e-13]    \n",
      "[  30,   30,   30,    0]    [SADD, SADD, SADD, NOP ]    [9.86e-05, 9.86e-05, 9.86e-05, 4.86e-05]    [9.86e-13, 9.86e-13, 9.86e-13, 4.86e-13]    \n",
      "[  18,   18,   18,  126]    [SADD, SADD, SADD, SADD]    [9.79e-05, 9.86e-05, 9.86e-05, 9.79e-05]    [9.79e-13, 9.86e-13, 9.86e-13, 9.79e-13]    \n",
      "Power: 1.41e-03 W, Energy: 1.41e-11 J\n",
      "Latency: 1 cc\n",
      "-------\n",
      "Instr =  21 ( 9 )\n",
      "[   9,    9,    9,    6]    [NOP , NOP , NOP , NOP ]    [3.93e-05, 3.93e-05, 3.93e-05, 3.94e-05]    [7.87e-13, 7.87e-13, 7.87e-13, 7.88e-13]    \n",
      "[   8,    8,    8,    0]    [NOP , NOP , NOP , NOP ]    [3.93e-05, 3.93e-05, 3.93e-05, 3.89e-05]    [7.87e-13, 7.87e-13, 7.87e-13, 7.78e-13]    \n",
      "[  30,   30,   30,    0]    [NOP , NOP , NOP , NOP ]    [3.93e-05, 3.93e-05, 3.93e-05, 3.89e-05]    [7.87e-13, 7.87e-13, 7.87e-13, 7.78e-13]    \n",
      "[  48,   48,   48,  126]    [SADD, SADD, SADD, SWD ]    [9.75e-05, 9.79e-05, 9.79e-05, 3.55e-05]    [1.95e-12, 1.96e-12, 1.96e-12, 7.11e-13]    \n",
      "Power: 8.00e-04 W, Energy: 1.60e-11 J\n",
      "Latency: 2 cc\n",
      "-------\n",
      "Instr =  22 ( 10 )\n",
      "[   9,    9,    9,    6]    [NOP , NOP , NOP , NOP ]    [4.94e-05, 4.94e-05, 4.94e-05, 4.95e-05]    [4.94e-13, 4.94e-13, 4.94e-13, 4.95e-13]    \n",
      "[   8,    8,    8,    0]    [NOP , NOP , NOP , NOP ]    [4.94e-05, 4.94e-05, 4.94e-05, 4.86e-05]    [4.94e-13, 4.94e-13, 4.94e-13, 4.86e-13]    \n",
      "[  30,   30,   30,    0]    [NOP , NOP , NOP , NOP ]    [4.94e-05, 4.94e-05, 4.94e-05, 4.86e-05]    [4.94e-13, 4.94e-13, 4.94e-13, 4.86e-13]    \n",
      "[  96,   48,   48,   48]    [SADD, NOP , NOP , SADD]    [9.79e-05, 4.94e-05, 4.94e-05, 9.79e-05]    [9.79e-13, 4.94e-13, 4.94e-13, 9.79e-13]    \n",
      "Power: 8.86e-04 W, Energy: 8.86e-12 J\n",
      "Latency: 1 cc\n",
      "-------\n",
      "Instr =  23 ( 11 )\n",
      "[   9,    9,    9,    6]    [NOP , NOP , NOP , NOP ]    [4.94e-05, 4.94e-05, 4.94e-05, 4.95e-05]    [4.94e-13, 4.94e-13, 4.94e-13, 4.95e-13]    \n",
      "[   8,    8,    8,    0]    [NOP , NOP , NOP , NOP ]    [4.94e-05, 4.94e-05, 4.94e-05, 4.86e-05]    [4.94e-13, 4.94e-13, 4.94e-13, 4.86e-13]    \n",
      "[  30,   30,   30,    0]    [NOP , NOP , NOP , NOP ]    [4.94e-05, 4.94e-05, 4.94e-05, 4.86e-05]    [4.94e-13, 4.94e-13, 4.94e-13, 4.86e-13]    \n",
      "[  96,   48,   48,  144]    [NOP , NOP , NOP , SADD]    [4.87e-05, 4.94e-05, 4.94e-05, 9.79e-05]    [4.87e-13, 4.94e-13, 4.94e-13, 9.79e-13]    \n",
      "Power: 8.37e-04 W, Energy: 8.37e-12 J\n",
      "Latency: 1 cc\n",
      "-------\n",
      "Instr =  24 ( 12 )\n",
      "[   9,    9,    9,    6]    [EXIT, NOP , NOP , NOP ]    [3.93e-05, 3.93e-05, 3.93e-05, 3.94e-05]    [7.87e-13, 7.87e-13, 7.87e-13, 7.88e-13]    \n",
      "[   8,    8,    8,    0]    [NOP , NOP , NOP , NOP ]    [3.93e-05, 3.93e-05, 3.93e-05, 3.89e-05]    [7.87e-13, 7.87e-13, 7.87e-13, 7.78e-13]    \n",
      "[  30,   30,   30,    0]    [NOP , NOP , NOP , NOP ]    [3.93e-05, 3.93e-05, 3.93e-05, 3.89e-05]    [7.87e-13, 7.87e-13, 7.87e-13, 7.78e-13]    \n",
      "[  96,   48,   48,  144]    [NOP , NOP , NOP , SWD ]    [3.90e-05, 3.93e-05, 3.93e-05, 3.55e-05]    [7.79e-13, 7.87e-13, 7.87e-13, 7.11e-13]    \n",
      "Power: 6.24e-04 W, Energy: 1.25e-11 J\n",
      "Latency: 2 cc\n",
      "\n",
      "Longest instructions per cycle:\n",
      "\n",
      "Cycle    Instruction               Latency (CC)\n",
      "1  (0)    MEM (LWD R0)              11        \n",
      "2  (1)    SMUL ROUT  R0  2          3         \n",
      "3  (2)    SADD ROUT  R0  0          1         \n",
      "4  (3)    MEM (LWD R0)              4         \n",
      "5  (4)    SMUL ROUT  R0  2          3         \n",
      "6  (5)    SADD ROUT  R0  0          1         \n",
      "7  (6)    MEM (LWD R0)              5         \n",
      "8  (7)    SMUL ROUT  R0  2          3         \n",
      "9  (5)    SADD ROUT  R0  0          1         \n",
      "10 (6)    MEM (LWD R0)              5         \n",
      "11 (7)    SMUL ROUT  R0  2          3         \n",
      "12 (5)    SADD ROUT  R0  0          1         \n",
      "13 (6)    MEM (LWD R0)              5         \n",
      "14 (7)    SMUL ROUT  R0  2          3         \n",
      "15 (5)    SADD ROUT  R0  0          1         \n",
      "16 (6)    MEM (LWD R0)              5         \n",
      "17 (7)    SMUL ROUT  R0  2          3         \n",
      "18 (5)    SADD ROUT  R0  0          1         \n",
      "19 (6)    MEM (LWD R0)              5         \n",
      "20 (7)    SMUL ROUT  R0  2          3         \n",
      "21 (8)    SADD ROUT  R0  0          1         \n",
      "22 (9)    SWD ROUT                  2         \n",
      "23 (10)   NOP                       1         \n",
      "24 (11)   NOP                       1         \n",
      "25 (12)   EXIT                      2         \n",
      "\n",
      "Configuration time: 13 CC\n",
      "Time between end of configuration and start of first iteration: 53 CC\n",
      "Total time for all instructions: 74 CC\n",
      "\n",
      "Power estimation for all instructions: 1.17e-03  W\n",
      "\n",
      "Average power per operation:\n",
      "\n",
      "8.93e-05 8.93e-05 8.93e-05 5.46e-05\n",
      "1.06e-04 1.06e-04 1.06e-04 3.57e-05\n",
      "1.06e-04 1.06e-04 1.06e-04 3.57e-05\n",
      "8.04e-05 6.49e-05 6.49e-05 5.46e-05\n",
      "\n",
      "Clock period used: 1e-08 s\n",
      "\n",
      "Total energy consumed during execution: 8.68e-10 J\n",
      "\n",
      "Energy per operation:\n",
      "\n",
      "6.60e-11 6.60e-11 6.60e-11 4.04e-11\n",
      "7.83e-11 7.83e-11 7.83e-11 2.64e-11\n",
      "7.85e-11 7.85e-11 7.85e-11 2.64e-11\n",
      "5.95e-11 4.80e-11 4.80e-11 4.04e-11\n",
      "\n",
      "\n",
      "END\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "sys.path.append(\"src/\")\n",
    "from cgra import *\n",
    "\n",
    "# Set the kernel name\n",
    "kernel_name = \"examples/convolution\"\n",
    "version = \"_v1\"\n",
    "# Input data\n",
    "clear_memory(kernel_name, version)\n",
    "add_memory_region(kernel_name, 36464, [1, 2, 3, 4, 5, 6, 7, 8, 9], version)\n",
    "add_memory_region(kernel_name, 100, [9], version)\n",
    "# Set load and write addrs\n",
    "load_addrs = [36464, 36464, 36464, 100]\n",
    "store_addrs = [0, 0, 0, 4]\n",
    "# Run the example\n",
    "# run(kernel_name, version=version, pr=[\"ROUT\",\"OPS\"], load_addrs=load_addrs, store_addrs=store_addrs)\n",
    "run(kernel_name, version=version, pr=[\"ROUT\",\"OPS\", \"ALL_LAT_INFO\", \"ALL_PWR_EN_INFO\"], load_addrs=load_addrs, store_addrs=store_addrs, limit=1000)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "3125a0e6",
   "metadata": {},
   "source": [
    "# Create a new kernel "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "88657fbf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Kernel examples/strsearch already exists!\n"
     ]
    }
   ],
   "source": [
    "from sat_to_csv import *\n",
    "from kernels import *\n",
    "\n",
    "# Kernels will be located in a folder with the kernel's name\n",
    "kernel_name = \"examples/strsearch\"\n",
    "\n",
    "# Create a new folder (if it does not exist already) and add the minimum necessary files to run it\n",
    "kernel_new(kernel_name)\n",
    "\n",
    "# If you have a assembly in the SAT-MapIt format, you can convert it to a csv\n",
    "convert( kernel_name+\"/out.sat\", kernel_name+\"/instructions.csv\" )\n",
    "\n",
    "# To test this kernel we will fill the memory with two random arrays\n",
    "# Note that the addresses in memory (36464 and 37800) correspond to inputs in the inputs.csv file)\n",
    "clear_memory(kernel_name)\n",
    "add_memory_region(kernel_name, 1000, [50, 123, 36464, 112, 37800, 45])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0baec11c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import cgra\n",
    "# Set load and write addrs\n",
    "load_addrs = [0, 1000, 1008, 1016]\n",
    "store_addrs = [0, 4, 0, 0]\n",
    "cgra.run( kernel_name, pr=[\"ROUT\", \"R0\",\"INST\"], limit=120, load_addrs=load_addrs, store_addrs=store_addrs)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "51334fa4",
   "metadata": {},
   "source": [
    "# Your turn to play around"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64ef2def",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
